<!-- ./idFieldRender.vue 文件 -->
<template>
    <view class="content">
            <el-button v-if="data[0]==2" type="success" size="small" @click="handleShop(1)">开启</el-button>
            <el-button v-if="data[0]==1" type="danger" size="small" @click="handleShop(2)">停用</el-button>
    </view>
</template>

<script setup lang="ts">
import { TableColumnCtx } from 'element-plus'
import { ref ,defineProps,inject} from 'vue'
import type baTableClass from '/@/utils/baTable'
const baTable = inject('baTable') as baTableClass
import { ElMessage,ElMessageBox} from 'element-plus'
import createAxios from "/@/utils/axios";
// BuildAdmin将自动为此组件传递五个Props
interface Props {
    renderValue: any // 单元格值
    renderRow: TableRow // 当前行数据
    renderField: TableColumn // 当前列数据
    renderColumn: TableColumnCtx<TableRow> // 当前列上下文数据
    renderIndex: number // 当前行号
}
const loading = ref(false)
const props = defineProps<Props>()
const data = props.renderValue
const handleShop = (t = 0)=>{
    var mess = (t==2)?'店铺停用，用户访问将无法展示店铺内容，确定停用吗？':'确定开启店铺吗？'
    ElMessageBox.confirm(
        mess,
        '系统提示',
        {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
        }
    ).then(() => {
            return createAxios({
                url: '/admin/store.Shop/shopStatus',
                params:{'sid':data[1],'os':t},
                method:'get',
            }).then(res => {
                baTable.getIndex()?.then(() => {
                    baTable.initSort()
                    baTable.dragSort()
                })
            })
        })
        .catch(() => {

        })
}
// console.log(props.renderValue, props.renderRow, props.renderField, props.renderColumn, props.renderIndex)
</script>

<style scoped lang="scss">
.content span{
    font-size: 10px;
}
.content{
    font-size: 14px;
}
.fl{
  float: left;
}
</style>
